﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.IoC;
using Kooboo.Domain;

namespace Kooboo.Commerce.Domain.Services
{
    public class SupportTicketService:ServiceBase<ISupportTicketRepository,ISupportTicket>
    {
        //internal SupportTicketService()
        //{
        //}

        public override IQueryable<ISupportTicket> QueryService
        {
            get 
            {
                return this.Repository.SupportTickets;
            }
        }

        public void Post(ISupportTicket supportTicket, bool hasTransaction = false)
        {
           
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Post(supportTicket);
                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Put(ISupportTicket supportTicket, bool hasTransaction = false)
        {
          
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Put(supportTicket);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Delete(ISupportTicket supportTicket, bool hasTransaction = false)
        {
       

            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Delete(supportTicket);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }
    }

 
}
